package netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * Created by IntelliJ
 * Author:熊磊
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {

        ChannelPipeline pipeline = socketChannel.pipeline();
        //加入netty提供的httpserverCode
        // 1. netty 提供的http编解码器
        pipeline.addLast("MyHttpServerCodec",new HttpServerCodec());
        // 2. 增加自定义的handler
        pipeline.addLast("MyTestServerHandler",new TestServerHandler());
    }
}
